<{include file="Public/top.html" }>
</head>
<body>
<div id="warpper">
    <div class="content">
        <div class="location">商户管理</div>
        <{include file= "Business/nav.html"}>
        <a class="return" href="<{U('restaurantList')}>">&lt;  返回</a>
        <div class="topic">添加商户信息</div>
        <div class="form-box border0 border-box">
            <form action="<{U('restaurantAdd')}>" method="post" class="ui-form" id="addManagerForm">


                <div class="ui-form-item2 uploader">
                    <input type="hidden" value="<{$obj.photo}>" name="photo">
                    <label class="ui-label">商户图片:</label>
                     <span class="picture_box picture_150">
                        <div class="a-imgBox" id="imgBox" style="display:none;">
                            <input type="hidden" name="pic">
                            <a href="javascript:void(0);" class="a-close" onclick="removeElement(this)"></a>
                            <img src="" width="150" height="130" />
                        </div>
                        <div>
                            <a href="javascript:;" class="a-upload">
                                <input type="file" name="file" id="" >
                            </a>
                            <i>上传图片</i>
                            <i>150*130</i>
                        </div>
                    </span>
                </div>


                <div class="ui-form-item">
                    <label class="ui-label">商户名称：</label>
                    <input type="text" class="ui-text" id="name" name="restaurantName"  required/>
                </div>
                <div class="ui-form-item">
                    <label class="ui-label">联系人：</label>
                    <input type="text" class="ui-text" id="director" name="director" />
                </div>
                <div class="ui-form-item">
                    <label class="ui-label">手机号：</label>
                    <input type="text" class="ui-text" id="phone" name="phone" />
                    <label class="ui-label">用于商户登陆</label>
                </div>
                <div class="ui-form-item">
                    <label class="ui-label">登陆密码：</label>
                    <input type="text" class="ui-text" id="password" name="password" />
                </div>
                <div class="integral_btn-group">
                    <input type="submit" value="提交" class="ui-button"/>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
<{include file="Public/foot.html" }>
<script>
    function removeElement(obj) {
//        document.getElementById(id).style.display="none";
        $(obj).parent('.a-imgBox').css('display','none');
        $(obj).prev().val('');
    }
    (function ($) {
        'use strict';
        $.fn.uploader = function () {
            return this.each(function () {
                var $this = $(this);
                var $img = $this.find('img');
                var $file = $this.find('input[type=file]');
                var $hidden = $this.find('input[type=hidden]');
                var $txt = $this.find('i.uptxt');
                var $imgBox = $this.find('div[id=imgBox]');
                // var $size = $this.find('span.size');
                /*$img.on('load', function () {
                 var width = $(this).width();
                 var height = $(this).height();
                 $hidden.val($img.attr('src'));
                 $size.text(width + 'x' + height);
                 });*/
                $file.AjaxFileUpload({
                    action: './api.php?m=Api&c=index&a=ajaxUpload&from=IMG_SHOP_STORE',
                    onSubmit: function () {
                        $txt.text('上传中');
                    },
                    onComplete: function (filename, response) {
                        if(parseInt(response.id)>0){
                            $txt.text("上传成功");
                            $hidden.attr('value', response.msg);
                            $img.attr("src",response.msg);
                            $imgBox.css('display','block');
                        }else{
                            $txt.text(response.msg);
                        }

                    }
                });
            });
        }
    })(jQuery);

    $('.uploader').uploader();
</script>